﻿package com.eitb.programas.menu.botones{
	import flash.text.*;
	import flash.events.*;
	import com.eitb.nielsen.*;
	import com.eitb.programas.menu.botones.*;

	public class BotonGris extends Boton implements IVistaBoton {
		
		public function BotonGris():void {
			super();
			this.addEventListener(MouseEvent.MOUSE_DOWN,downBoton);
			this.addEventListener(MouseEvent.MOUSE_UP,upBoton);
			this.addEventListener(MouseEvent.MOUSE_OVER,overBoton);
			this.addEventListener(MouseEvent.MOUSE_OUT,outBoton);
		}
		
		// EVENTOS
		private function downBoton(event:MouseEvent):void {
			this.seleccionado();
		}
		private function upBoton(event:MouseEvent):void {
			this.seleccionar();
		}
		private function overBoton(event:MouseEvent):void {
			this.activo();
		}

		private function outBoton(event:MouseEvent):void {
			if (this.cBoton.isSeleccionado()) {
				this.seleccionado();
			} else {
				this.reposo();
			}
		}
		// EVENTOS

		public function activo():void {
			this.gotoAndStop(Boton.ACTIVO);
			for each (var texto in this.textos) {
				texto.textColor="0x000000";
			}			
		}
		
		public function reposo():void {
			this.cBoton.setSeleccionado(false);
			this.gotoAndStop(Boton.REPOSO);
			for each (var texto in super.textos) {
				texto.textColor="0x000000";
			}
		}

		public function seleccionar():void {
			this.cMenu.reposarBotones();
			this.cBoton.setSeleccionado(true);
			this.seleccionado();
			this.cMenu.ocultarPlantillas();
			this.cMenu.loadImagenes();
			var id:String = new String();
			for each (var texto in this.textos) {
				id.concat(texto.text);
			}				
			new NielsenCall("boton_".concat(id)).doPing();
		}
		
		
		public function seleccionado():void {
			this.gotoAndStop(Boton.SELECCIONADO);
			for each (var texto in this.textos) {
				texto.textColor="0xFFFFFF";
			}
		}
	}
}